// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.16.10
package sys

import (
	"context"
	"hotgo/api/admin/systenant"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	SysTenant = cSysTenant{}
)

type cSysTenant struct{}

// List 查看租户列表列表
func (c *cSysTenant) List(ctx context.Context, req *systenant.ListReq) (res *systenant.ListRes, err error) {
	list, totalCount, err := service.SysTenant().List(ctx, &req.SysTenantListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.SysTenantListModel{}
	}

	res = new(systenant.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Export 导出租户列表列表
func (c *cSysTenant) Export(ctx context.Context, req *systenant.ExportReq) (res *systenant.ExportRes, err error) {
	err = service.SysTenant().Export(ctx, &req.SysTenantListInp)
	return
}

// Edit 更新租户列表
func (c *cSysTenant) Edit(ctx context.Context, req *systenant.EditReq) (res *systenant.EditRes, err error) {
	err = service.SysTenant().Edit(ctx, &req.SysTenantEditInp)
	return
}

// View 获取指定租户列表信息
func (c *cSysTenant) View(ctx context.Context, req *systenant.ViewReq) (res *systenant.ViewRes, err error) {
	data, err := service.SysTenant().View(ctx, &req.SysTenantViewInp)
	if err != nil {
		return
	}

	res = new(systenant.ViewRes)
	res.SysTenantViewModel = data
	return
}

// Delete 删除租户列表
func (c *cSysTenant) Delete(ctx context.Context, req *systenant.DeleteReq) (res *systenant.DeleteRes, err error) {
	err = service.SysTenant().Delete(ctx, &req.SysTenantDeleteInp)
	return
}

// Status 更新租户列表状态
func (c *cSysTenant) Status(ctx context.Context, req *systenant.StatusReq) (res *systenant.StatusRes, err error) {
	err = service.SysTenant().Status(ctx, &req.SysTenantStatusInp)
	return
}